<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="http://i.irenren.net//jquery-1.8.0.min.js"></script>
</head>
<body>
<textarea id="t1" style="width: 600px; height:600px;"></textarea>


<textarea id="t2" style="width:400px; height:600px; border: none" readonly></textarea>
<textarea id="t3" style="width:400px; height:600px; border: none" readonly></textarea>
<pre id="show"></pre>
<div><button id="commit">转换</button></div>

<script>
    $('#commit').click(function(){
        var content = $('#t1').val();

        var c = content.split("\n")
        var eng = [];
        var chi = [];
        var chiMan = {};
        for(var i=0; i< c.length; i++){
            var text = c[i];
            if($.trim(text) == ''){
                chi.push(text)
                eng.push(text)
            }else{
                var q=0;
                if(/[\u4e00-\u9fa5]/.test(text)){
                    chi.push(text);
                     if((q=text.indexOf("："))>=0){
                        var man=text.substr(0, q);
                        chiMan[man] = chiMan[man] || 0;
                        content = text.substr(q+1);
                        console.log(content);
                        if(!/^（.*?）$/.test(content)){
                            chiMan[man]++; 
                        }

                }
                }else{
                    eng.push(text);
                }
            }

        }
        $('#t2').val(eng.join("\n"));
        $('#t3').val(chi.join("\n"));
        var htmlstr = '';
        for(var k in chiMan){
             htmlstr += "\n"+k+":"+chiMan[k];
        
        
        }



        $('#show').text(htmlstr);
    })

</script>

</body>
</html>
